#include "e2d/imgui/render/Editor.h"
#include "e2d/core/render/components.h"
#include "sysx/System.h"

using Editor = e2d::BasicEditor;

template<>
bool Editor::Edit<e2d::CameraViewEdit>(const std::string& l, e2d::CameraViewEdit& e)
{
    int index = 4;

    EditInst<e2d::CameraView>("cameraView", e);

    if (TreeNode("pickup RTT", e.m_ImguiFlag, index++))
    {
        EditInst<e2d::RenderTargetJack>("pickup Out", *e.m_PickRT);
        TreePop();
    }

    if (TreeNode("GBuffer RTT", e.m_ImguiFlag, index++))
    {
        EditInst<e2d::RenderTargetJack>("pickup Out", *e.m_GBufferRT);
        TreePop();
    }

    if (TreeNode("EntityKeyMap", e.m_ImguiFlag, index++))
    {
        e2d::CustomEditor::ComboEditEntity("m_ParentEntity", e.m_ParentEntity, e.m_Entity->m_Scene->m_AllEntitiesCalculatedNoPrefeb);

        for (auto& it : e.m_EntityKeyMaps)
        {
            ImGui::PushID(&it);
            ImGui::SetNextItemWidth(100);
            e2d::CustomEditor::ComboEditEntity("Entity", it.m_EntityMap, e.m_Entity->m_Scene->m_AllEntitiesCalculatedNoPrefeb);

            ImGui::SameLine();
            ImGui::SetNextItemWidth(100);
            InputInst<int>("Key", it.m_Keydown);
            
            ImGui::PopID();
        }

        if (ImGui::Button("+"))
        {
            e.m_EntityKeyMaps.push_back({});
        }
        TreePop();
    }


    return false;

}